<?php defined('_JEXEC') or die('Restricted access');
JHTML::_('behavior.tooltip');
jimport('joomla.filesystem.file');
$document =& JFactory::getDocument();
$lang =& JFactory::getLanguage();

switch ($lang->getTag())
{
	case 'de-DE' :
		$title = 'Immobilien';
		break;
	case 'en-GB' :
		$title = 'Properties';
		break;
	case 'es-ES' :
		$title = 'Propiedades';
		break;
	case 'ru-RU' :
		$title = JText::_('Title Properties');
		break;
}


//$title = JText::_('Title Properties');

$cid = JRequest::getVar('cid', 0, '', 'int');
$tid = JRequest::getVar('tid', 0, '', 'int');
if (JRequest::getVar('cid') ) {

	$title .=' - '.$this->NameCategory[$cid];
}
if (JRequest::getVar('tid') ) {

	$title .=' - '.$this->NameType[$tid];
}
$document->setTitle( $title );

$document->setDescription( $title );
$document->setMetadata('keywords',$title);

$component = JComponentHelper::getComponent( 'com_properties' );
$params = new JParameter( $component->params );
$ShowOrderBy=$params->get('ShowOrderBy');
$ShowOrderByDefault=$params->get('ShowOrderByDefault');
$ActivarMapa=$params->get('ActivarMapa');
//$MostrarBuscar=$params->get('MostrarBuscar');
$currencyformat=$params->get('FormatPrice');
$PositionPrice=$params->get('PositionPrice');
$SimbolPrice=$params->get('SimbolPrice');
if($this->noShow['MostrarCarousel']){$MostrarCarousel=0;}else{$MostrarCarousel=$params->get('MostrarCarousel');}
if($this->noShow['MostrarBuscar']){$MostrarBuscar=0;}else{$MostrarBuscar=$params->get('MostrarBuscar');}

$linkAjax= JURI::base().'index.php?option=com_properties&controller=searchajax&format=raw&task=SearchAjax&langg='.$lang->getTag();


$view = JRequest::getVar('view');
$cyid = JRequest::getVar('cyid', 0, '', 'int');
$id = JRequest::getVar('id', 0, '', 'int');
$cid = JRequest::getVar('cid', 0, '', 'int');
$tid = JRequest::getVar('tid', 0, '', 'int');
$aid = JRequest::getVar('aid', 0, '', 'int');
$task = JRequest::getVar('task');
//echo 'cid: '.$cid.' tid: '.$tid.' id: '.$id.' view: '.$view.' task: '.$task.' cyid: '.$cyid.'<br>';
//echo 'aid: '.$aid.'<br>';
//print_r($this->NameCategory);
?>

<script type="text/javascript">
function SearchAjax(idCy,idS,idL,idC,idT){
var progressS = $('progressS');
new Ajax("<?php echo $linkAjax;?>", 
{method: 'get',	
onRequest: function(){progressS.setStyle('visibility', 'visible');},
onComplete: function(){progressS.setStyle('visibility', 'hidden');},
update: $('logB'), 
data: '&cyid='+idCy+'&sid='+idS+'&lid='+idL+'&cid='+idC+'&tid='+idT}).request();
			}
</script>

<div id="propiedades"><?php

if($MostrarBuscar == 1){?>

<div id="buscador">
<div id="accordion1">
<div class="element">
<div class="innerelementBuscar">
<div class="formbuscar">

<form name="FormBuscar" id="FormBuscar"
	action="<?php echo JRoute::_( 'index.php?option=com_properties&amp;task=search') ?>"
	method="post">
<div id="logB" style="float: left;"></div>
<!-- thuan edit 08-09-09 -->
<div id="progressS" style="width: 50px;"></div>
<div style="float: left;"><label style="color: black;">Address:</label> <input type="textbox" name="address" size="50" style="font-size: 10px;font-family: verdana;"></div>
<div class="separator_search"></div>
<div class="button_search" style="width: 300px;"><input type="hidden" name="option"
	id="option" value="com_properties" /> <input type="hidden" name="task"
	id="task" value="search" /> <!--<input type="hidden" name="limitstart" id="limitstart" value="" />
	<input type="hidden" name="start" id="start" value="" />
	--> <input value="<?php echo JText::_('Search'); ?> "
	class="form2_submit" type="submit" /></div>
	<!-- thuan end edit 08-09-09 -->
<?php

$tid = 0;$cid = 0;$lid = 0;$sid = 0;$cyid = 0;
if(JRequest::getVar('cyid')){
	$cyid = JRequest::getVar('cyid', 0, '', 'int');

	if(JRequest::getVar('sid')){
		$sid = JRequest::getVar('sid', 0, '', 'int');
		if(JRequest::getVar('lid')){
			$lid = JRequest::getVar('lid', 0, '', 'int');
		}else{
			$lid = 0;
		}
	}else{$sid = 0;}
}else{
	$cyid = 0;
}

if(JRequest::getVar('cid')){
	$cid = JRequest::getVar('cid', 0, '', 'int');
}else{
	$cid = 0;
}
if(JRequest::getVar('tid')){
	$tid = JRequest::getVar('tid', 0, '', 'int');
}else{
	$tid = 0;
}


/*
 echo '<script type="text/javascript">
 window.onload = SearchAjax('.$cyid.','.$sid.','.$lid.','.$cid.','.$tid.');
 </script>';
 */
//echo $link_ciudad[52];?></form>
</div>
<!--formBuscar--></div>
<!--innerelementBuscar--></div>
<!-- element-->
<div class="toggler"
	onclick="javascript: SearchAjax(<?php echo $cyid.','.$sid.','.$lid.','.$cid.','.$tid;?>); "></div>
</div>
<!--acordion1 -->

<div style="clear: both"></div>
</div>
<!--buscador --> <?php } ?> <?php if($MostrarCarousel == 1){?>
<div align="center">
<div id="NewsTicker"><!-- <h1>What's news? Visit <a href="http://woork.blogspot.com/">Woork.blogspot.com</a></h1>-->
<div id="NewsVertical">
<ul id="TickerVertical">
<?php
$k = 0;
for ($i=0, $n=count( $this->Last10Products ); $i < $n; $i++)
{
	$row = &$this->Last10Products[$i];

	$link 		= JRoute::_( 'index.php?option=com_properties&amp;view=property&amp;cid='.$row->Cslug.'&amp;tid='.$row->Typeslug.'&amp;id='.$row->Pslug.'&amp;Itemid='.$this->Itemid->id);

	?>
	<li><a href="<?php echo $link; ?>"> <img
		src="images/properties/peques/peque_<?php echo $row->image1;?>"
		border="0" class="NewsImg" height="75" /> </a> <span class="NewsTitle">
	<a href="<?php echo $link; ?>"><?php echo $row->name; ?></a></span> <?php echo JText::_('Category'); ?>:
	<?php echo $this->NameCategory[$row->parent]; ?><br />
	<?php echo JText::_('Type'); ?>: <?php echo $this->NameType[$row->type]; ?><br />
	</span></li>
	<?php
}
?>
</ul>
</div>
</div>
<div style="clear: both"></div>
</div>

<script language="javascript" type="text/javascript">
var Ticker = new Class({
				setOptions: function(options) {
					this.options = Object.extend({
						speed: 5000,
						delay: 5000,
						direction: 'horizontal',
						onComplete: Class.empty,
						onStart: Class.empty
					}, options || {});
				},
				initialize: function(el,options){
					this.setOptions(options);
					this.el = $(el);
					this.items = this.el.getElements('li');
					var w = 0;
					var h = 0;
					if(this.options.direction.toLowerCase()=='horizontal') {
						h = this.el.getSize().size.y;
						this.items.each(function(li,index) {
							w += li.getSize().size.x;
						});
					} else {
						w = this.el.getSize().size.x;
						this.items.each(function(li,index) {
							h += li.getSize().size.y;
						});
					}
					this.el.setStyles({
						position: 'absolute',
						top: 0,
						left: 0,
						width: w,
						height: h
					});
					this.fx = new Fx.Styles(this.el,{duration:this.options.speed,onComplete:function() {
						var i = (this.current==0)?this.items.length:this.current;
						this.items[i-1].injectInside(this.el);
						this.el.setStyles({
							left:0,
							top:0
						});
					}.bind(this)});
					this.current = 0;
					this.next();
				},
				
				
				next: function() {
					this.current++;
					if (this.current >= this.items.length) this.current = 0;
					var pos = this.items[this.current];
					this.fx.start({
						top: -pos.offsetTop,
						left: -pos.offsetLeft
					});
					this.next.bind(this).delay(this.options.delay+this.options.speed);
				}
			});

			var hor = new Ticker('TickerVertical',{speed:1000,delay:4000,direction:'horizontal'});




			
		</script> <?php }?> <?php if($this->DataAgent->show ){?>
<div id="topagent"><img
	src="<?php echo JURI::base().'/images/properties/profiles/'.$this->DataAgent->logo_image_large; ?>" />
</div>
<div id="datagent" style="margin-top: 5px;">
<div id="imageagent"><img
	src="<?php echo JURI::base().'/images/properties/profiles/'.$this->DataAgent->image; ?>"
	align="left" /> <!--</div>
<div id="descagent">--> <?php if($this->DataAgent->name){echo JText::_('Name').' : '.$this->DataAgent->name.'<br />';} ?>
<?php if($this->DataAgent->company){echo JText::_('Company').' : '.$this->DataAgent->company.'<br />';} ?>
<?php if($this->DataAgent->properties){echo JText::_('Properties').' : '.$this->DataAgent->properties.'<br />';} ?>
<?php if($this->DataAgent->address1){echo JText::_('Address').' : '.$this->DataAgent->address1.'<br />';} ?>
<?php if($this->DataAgent->locality){echo JText::_('Locality').' : '.$this->DataAgent->locality.'<br />';} ?>
<?php if($this->DataAgent->email){echo JText::_('Email').' : '.$this->DataAgent->email.'<br />';} ?>
<?php if($this->DataAgent->phone){echo JText::_('Phone').' : '.$this->DataAgent->phone.'<br />';} ?>
<?php if($this->DataAgent->fax){echo JText::_('Fax').' : '.$this->DataAgent->fax.'<br />';} ?>
<?php if($this->DataAgent->mobile){echo JText::_('Mobile').' : '.$this->DataAgent->mobile.'<br />';} ?>
</div>
<div style="clear: both"></div>
</div>

<?php
/*
 echo '<pre>';
 print_r($post);
 echo '</pre>';
 */
		}
		print_r($this->ThisAgent);
		?>
<div style="width: 100%; height: 15px;"></div>

<div id="accordion">
<div id="ShowOrderBy"><?php require_once( JPATH_COMPONENT.DS.'helpers'.DS.'orderby.php' );?>
</div>

<form
	action="index.php?option=com_properties&amp;controller=property&amp;Itemid="
	method="post" name="Form" id="Form"><input type="hidden" name="task"
	value="" /> <input type="hidden" name="controller" value="property" />

<div style="clear: both"></div>

		<?php
		$k = 0;
		for ($i=0, $n=count( $this->items ); $i < $n; $i++)
		{
			$row = &$this->items[$i];

			$link 		= JRoute::_( 'index.php?option=com_properties&amp;view=property&amp;cid='.$row->Cslug.'&amp;tid='.$row->Typeslug.'&amp;id='.$row->Pslug.'&amp;Itemid='.$this->Itemid->id);
			?>
<div class="producto"><?php 
/*
 DETAILS MARKET=Market Status
 DETAILS_MARKET0=Available
 DETAILS_MARKET1=Leased
 DETAILS_MARKET2=Sold
 DETAILS_MARKET3=Under Offer
 DETAILS_MARKET4=Subject to Contract
 DETAILS_MARKET5=Under Contract
 DETAILS_MARKET6=Unavailable
 */
?> <?php
$watermark='DETAILS_MARKET'.$row->available.'-'.$lang->getTag().'.png';

if($row->image1!=NULL){ $img=$row->image1;}else{$img='noimage.jpg';}
$destino_imagen = JPATH_SITE.DS.'images'.DS.'properties'.DS.'peques'.DS.'peque_'.$img;
if (JFile::exists($destino_imagen)){



	$InfoImage=getimagesize($destino_imagen);
	$width=$InfoImage[0];
	$height=$InfoImage[1];

	//echo	$width.$height;

	$imgTag='<img src="images/properties/peques/peque_'. $img .'" alt="'. str_replace('"',' ',$row->name) .'" width="100" height="75" />';

}else{$imgTag='<img src="images/properties/peques/peque_noimage.jpg" width="100" height="75"/>';}
?>
<div class="detalles">
<div class="imagendetalles">
<div class="watermark_box"><a href="<?php echo $link; ?>"> <?php echo $imgTag;?>
<img
	src="<?php echo JURI::base().'/components/'.'com_properties/'.'includes/'.'img/'.$watermark; ?>"
	class="watermark"
	alt="<?php echo JText::_('DETAILS_MARKET'.$row->available); ?>" /> </a>
</div>
</div>
<div class="datos"><a href="<?php echo $link; ?>"><?php echo $row->name; ?></a><br />
<?php echo JText::_('Category'); ?>: <?php echo $this->NameCategory[$row->parent]; ?><br />
<?php echo JText::_('Type'); ?>: <?php echo $this->NameType[$row->type]; ?><br />
<?php echo JText::_('Country'); ?>: <?php echo $this->NameCountry[$row->cyid]; ?><br />
<?php echo JText::_('State'); ?>: <?php echo $this->NameState[$row->sid]; ?><br />
<?php echo JText::_('Locality'); ?>: <?php echo $this->NameLocality[$row->lid]; ?><br />
</div>
</div>
<div class="togagent"><?php
$imgAgent=1;

if($row->logo_image_profile){
	?>
<div class="agent" style=""><img
	src="images/properties/profiles/<?php echo $row->logo_image_profile;?>"
	width="140" height="45" alt="<?php echo $row->agent;?>" /></div>
	<?php }?>

<div class="toggler"></div>
</div>

<div class="element">
<div class="innerelement"><?php 
$destino_imagen = JPATH_SITE.DS.'images'.DS.'properties'.DS.'peques'.DS.'peque_';

if($row->image2!=NULL & JFile::exists($destino_imagen.$row->image2)){
	$img=$row->image2;?> <a href="images/properties/<?php echo $img; ?>"
	rel="mediabox[640 480]"
	title="<?php echo str_replace('"',' ',$row->name); ?>"> <img
	width="90px" height="65px"
	src="images/properties/peques/peque_<?php echo $row->image2; ?>"
	alt="<?php echo str_replace('"',' ',$row->name); ?>" /></a> <?php }

	if($row->image3!=NULL & JFile::exists($destino_imagen.$row->image3)){
		$img=$row->image3;?> <a href="images/properties/<?php echo $img; ?>"
	rel="mediabox[640 480]"
	title="<?php echo str_replace('"',' ',$row->name); ?>"> <img
	width="90px" height="65px"
	src="images/properties/peques/peque_<?php echo $row->image3; ?>"
	alt="<?php echo str_replace('"',' ',$row->name); ?>" /></a> <?php }

	if($row->image4!=NULL & JFile::exists($destino_imagen.$row->image4)){
		$img=$row->image4;?> <a href="images/properties/<?php echo $img; ?>"
	rel="mediabox[680 530]"
	title="<?php echo str_replace('"',' ',$row->name); ?>"> <img
	width="90px" height="65px"
	src="images/properties/peques/peque_<?php echo $row->image4; ?>"
	alt="<?php echo str_replace('"',' ',$row->name); ?>" /></a> <?php }

	if($row->image5!=NULL & JFile::exists($destino_imagen.$row->image5)){
		$img=$row->image5;?> <a href="images/properties/<?php echo $img; ?>"
	rel="mediabox[680 530]"
	title="<?php echo str_replace('"',' ',$row->name); ?>"> <img
	width="90px" height="65px"
	src="images/properties/peques/peque_<?php echo $row->image5; ?>"
	alt="<?php echo str_replace('"',' ',$row->name); ?>" /></a> <?php }

	if($row->image6!=NULL & JFile::exists($destino_imagen.$row->image6)){
		$img=$row->image6;?> <a href="images/properties/<?php echo $img; ?>"
	rel="mediabox[680 530]"
	title="<?php echo str_replace('"',' ',$row->name); ?>"> <img
	width="90px" height="65px"
	src="images/properties/peques/peque_<?php echo $row->image6; ?>"
	alt="<?php echo str_replace('"',' ',$row->name); ?>" /></a> <?php }?>



<div class="detalleProducto" style="width: 50%; float: left;"><?php
if($row->price!=0){
	$number = $row->price;
	if ($currencyformat==0) {
		$formatted_price = number_format($number);
	} else if ($currencyformat==1) {
		$formatted_price = number_format($number, 2,".",",");
	} else if ($currencyformat==2) {
		$formatted_price = number_format($number, 0,",",".");
	} else if ($currencyformat==3) {
		$formatted_price = number_format($number, 2,",",".");
	}
	if($PositionPrice==0){
		echo JText::_('Price'); ?>: <?php echo $SimbolPrice.' '. $formatted_price;
	}else{
		echo JText::_('Price'); ?>: <?php echo $formatted_price .' '. $SimbolPrice;
	}
	echo '<br />';
}
?> <?php if($row->adress){echo JText::_('Address') .' : '. $row->adress.'<br />';} ?>
<?php if($row->years){echo JText::_('Years') .' : '. $row->years.'<br />';} ?>
<?php if($row->bedrooms){echo JText::_('Bedrooms') .' : '. $row->bedrooms.'<br />';} ?>
<?php if($row->bathrooms){echo JText::_('Bathrooms') .' : '. $row->bathrooms.'<br />';} ?>
<?php if($row->garage){echo JText::_('Garage') .' : '. $row->garage.'<br />';} ?>
<?php if($row->area){echo JText::_('Total Area') .' : '. $row->area.' '.JText::sprintf('Simbol Metric').'<br />';} ?>
<?php if($row->covered_area){echo JText::_('Covered Area') .' : '. $row->covered_area.' '.JText::sprintf('Simbol Metric').'<br />';} ?>
<?php if($row->available){echo JText::_('DETAILS MARKET').' : '.JText::_('DETAILS_MARKET'.$row->available).'<br />';} ?>
<br />
</div>
<div class="detalleProducto" style="width: 50%; float: left;"><?php echo $row->description; ?><br />

<?php //echo $this->ThisAgent[$row->agent_id]->name; ?><br />



<br />
<?php
$rutaG= 'index.php?option=com_properties&amp;controller=googlemap&amp;task=map&amp;tmpl=component&amp;id='.$row->id;
$rutaA= 'index.php?option=com_properties&amp;task=agentlisting&amp;aid='.$row->agent_id;
$rutaAdd = 'index.php?option=com_properties&task=addlightbox&tmpl=component&id='.$row->id;

if($ActivarMapa == 1){
	?> <a href="<?php echo JRoute::_( $rutaG );?>" rel="mediabox[690 510]"
	title="<?php echo str_replace('"',' ',$row->name); ?>"><?php echo JText::_('See in map'); ?></a><br />
	<?php }?> <?php $status = 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=500,height=400,directories=no,location=no';?>

<a href="javascript:void(0)"
	onclick="window.open('<?php echo JRoute::_( $rutaAdd ); ?>','win2','<?php echo $status; ?>');"
	title="<?php echo JText::_('Add Short List'); ?>"><?php echo JText::_('Add Short List'); ?></a>


<br />
<a href="<?php echo JRoute::_( $rutaA );?>"><?php echo JText::_('View Properties from this Agent'); ?></a><br />
</div>

</div>
<!--innerelement--></div>
<!-- element--></div>
<!--producto --> <?php
$k = 1 - $k;
		}
		?></form>
</div>
<!-- acordeon-->



<div id="pagination" style=""><?php require_once( JPATH_COMPONENT.DS.'helpers'.DS.'pagelinks.php' );?>
<div style="clear: both;"></div>
</div>
<!-- paginacion--> <br />
<br />
<div id="tareas"><?php require_once( JPATH_COMPONENT.DS.'helpers'.DS.'tasklinks.php' );?>







</div>










</div>
<!-- propiedades-->

		<?php
		/*
		 echo '<pre>';
		 print_r($row);
		 echo '</pre>';
		 */
		?>